class Solution {
public:
    int longestPalindrome(string s) {
        int flag=1;
        unordered_map<char,int> count;
        for(auto&ch:s)
        {
            count[ch]++;
        }
        
        int ret=0;
        for(auto&ch:count)
        {
            int tem=ch.second;
            if(tem%2==0)
            {
                ret+=tem;
            }
            else
            {
                //奇数的话我们拿到偶数个
                ret+=tem/2*2;
                flag=0;
            }
        }
        if(flag==1)
        {
            return ret;
        }
        else
        {
            return ret+1;
        }

    }
};